﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="mtaevasukohad_asukoht", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MtaevasukohadAsukoht))]
    public class MtaevasukohadAsukohtSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMtaevasukohadAsukoht clazz;
        
        public MtaevasukohadAsukohtSerializer(IMtaevasukohadAsukoht clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.ReaId!=null) {
                Writer.WriteStartElement("rea_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.ReaId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Ark!=null) {
                Writer.WriteStartElement("ark");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Ark))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Eltyyp!=null) {
                Writer.WriteStartElement("eltyyp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eltyyp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Haldyks!=null) {
                Writer.WriteStartElement("haldyks");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Haldyks))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Aadress!=null) {
                Writer.WriteStartElement("aadress");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Aadress))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Indeks!=null) {
                Writer.WriteStartElement("indeks");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Indeks))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Riik!=null) {
                Writer.WriteStartElement("riik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Riik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlgusKpv!=null) {
                Writer.WriteStartElement("algus_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AlgusKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LoppKpv!=null) {
                Writer.WriteStartElement("lopp_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.LoppKpv))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="rea_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaevasukohad_asukoht>rea_id");
                }
                clazz.ReaId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("rea_id")).Value;
            }
            if (Reader.LocalName=="ark") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaevasukohad_asukoht>ark");
                }
                clazz.Ark = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ark")).Value;
            }
            if (Reader.LocalName=="eltyyp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaevasukohad_asukoht>eltyyp");
                }
                clazz.Eltyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eltyyp")).Value;
            }
            if (Reader.LocalName=="haldyks") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaevasukohad_asukoht>haldyks");
                }
                clazz.Haldyks = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("haldyks")).Value;
            }
            if (Reader.LocalName=="aadress") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaevasukohad_asukoht>aadress");
                }
                clazz.Aadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress")).Value;
            }
            if (Reader.LocalName=="indeks") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaevasukohad_asukoht>indeks");
                }
                clazz.Indeks = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("indeks")).Value;
            }
            if (Reader.LocalName=="riik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaevasukohad_asukoht>riik");
                }
                clazz.Riik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("riik")).Value;
            }
            if (Reader.LocalName=="algus_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaevasukohad_asukoht>algus_kpv");
                }
                clazz.AlgusKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("algus_kpv")).Value;
            }
            if (Reader.LocalName=="lopp_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaevasukohad_asukoht>lopp_kpv");
                }
                clazz.LoppKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("lopp_kpv")).Value;
            }
        }
    }
}
